<table id="manage_agencyInfo" data-options="fit:true"></table>
<script>
$(function(){
	$('#manage_agencyInfo').datagrid({
		url:'../json/AgencyInfo_getAgencyInfoList',
		loadMsg:'数据加载中...',
		fitColumns:true,
		rownumbers:true,
		striped:true,
		sortName:'aid',
		sortOrder:'asc',
		remoteSort:false,
		columns:[[
			{field:'atids',title:'',width:100,align:'center',checkbox:true},
			{field:'aid',title:'编号',width:30,align:'center',sortable:true},
			{field:'aname',title:'旅行社名称',width:100,align:'center'}, 
			{field:'aintroduce',title:'旅行社简介',width:100,align:'center'},
			{field:'aaddr',title:'旅行社地址',width:100,align:'center'},
			{field:'aprice',title:'均价',width:50,align:'center'},
			{field:'atel',title:'联系方式',width:50,align:'center'}
		]],
		toolbar: [{
			iconCls: 'icon-add',
			text:'添加',
			handler: function(){
				$("#add_agencyInfo").dialog("open");
			}
		},'-',{
			iconCls: 'icon-remove',
			text:'删除',
			handler: function(){
				alert('help')
			}
		}]
	});
});

function addAgencyInfo(){
	var aname=$("#agency_aname").val();
	var aaddr=$("#agency_aaddr").val();
	var atel=$("#agency_atel").val();
	var aprice=$("#agency_aprice").val();
	var aintroduce=$("#agency_aintroduce").val();
	$.ajax({
	    url: "../json/AgencyInfo_addAgencyInfo",    //请求的url地址
	    dataType: "json",   //返回格式为json
	    async: true, //请求是否异步，默认为异步，这也是ajax重要特性
	    type: "POST",
	    data:{
	    	"aname":aname,
	    	"aaddr":aaddr,
	    	"atel":atel,
	    	"aprice":aprice,
	    	"aintroduce":aintroduce
	    },
	    success: function(data) {
	    	if(parseInt($.trim(data.obj))>=1){
	    		$.messager.show({
					title:'成功提示',
					msg:'添加信息成功！',
					timeout:3000,
					showType:'slide'
				});
	    		$("#add_agencyInfo").dialog("close");
	    		$("#agency_aname").val("");
	    		$("#agency_aaddr").val("");
	    		$("#agency_atel").val("");
	    		$("#agency_aprice").val("");
	    		$("#agency_aintroduce").val("");
				$('#manage_agencyInfo').datagrid("reload");
	    	}else{
	    		$.messager.alert('错误提示','添加信息失败,请稍后重试!','error');
	    	}
	    }
	});
}

</script>
<div id="add_agencyInfo" class="easyui-dialog" title="添加旅行社信息" style="width:400px;height:330px;"
	data-options="iconCls:'icon-add',resizable:true,modal:true,closed:true">
	<div style="margin-left: 20px;">
		<br /> <br /> 
		<label for="agency_aname">旅行社名称：</label><input type="text" id="agency_aname">
		<br /> <br /> 
		<label for="agency_aaddr">旅行社地址：</label><input type="text" id="agency_aaddr">
		<br/><br/>
		<label for="agency_atel">联系方式：</label><input type="text" id="agency_atel">
		<br/><br/>
		<label for="agency_aprice">均&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;价：</label><input type="text" id="agency_aprice">
		<br/><br/>
		<label for="agency_aintroduce" style="vertical-align: top">简介：</label><textarea rows="2" cols="50" id="agency_aintroduce"></textarea>
		<br/><br/>
		<center><input style="padding:5px 25px;" type="button" onclick="addAgencyInfo()" value="添加"></center>
	</div>
</div>